package com.sise.aio和bio和nio.aio.基于aio的聊天室;

import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.AsynchronousSocketChannel;
import java.util.concurrent.Future;

/**
 * @author idea
 * @data 2019/1/22
 */
public class Client {

    public static void main(String[] args) throws Exception{
        AsynchronousSocketChannel channel = AsynchronousSocketChannel.open();
        channel.connect(new InetSocketAddress(InetAddress.getLocalHost(),9000)).get();
        ByteBuffer buffer = ByteBuffer.wrap("中文,你好".getBytes());
        Future<Integer> future = channel.write(buffer);

        future.get();
        System.out.println("send ok");
        Thread.sleep(10000);
    }
}
